Skip to content

feat: added Get/Set Environment on Scope#5772

Open
bitsandfoxes wants to merge 4 commits into
mainfrom
feat/scope-set-environment
Open

feat: added Get/Set Environment on Scope#5772
bitsandfoxes wants to merge 4 commits into
mainfrom
feat/scope-set-environment

Conversation

@bitsandfoxes

Copy link
Copy Markdown
Contributor

📜 Description

Adds a getter and setter to the scope that allows users to configure the Environment at runtime.

💡 Motivation and Context

See #5769

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

🔮 Next steps

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against f3b38ec

@sentry

sentry Bot commented Jul 16, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.49.0 (1) release

⚙️ sentry-android Build Distribution Settings

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 324.54 ms 361.39 ms 36.85 ms
Size 0 B 0 B 0 B

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
b193867 331.08 ms 397.06 ms 65.98 ms
3d205d0 352.15 ms 432.53 ms 80.38 ms
22ff2c7 306.60 ms 336.65 ms 30.05 ms
a5ab36f 320.47 ms 389.77 ms 69.30 ms
539ca63 313.51 ms 355.43 ms 41.92 ms
dba088c 365.46 ms 366.31 ms 0.85 ms
4e3e79d 312.02 ms 376.24 ms 64.22 ms
7314dbe 437.83 ms 505.64 ms 67.81 ms
ad8da22 314.38 ms 352.29 ms 37.91 ms
bb0ff41 344.70 ms 413.82 ms 69.12 ms

App size

Revision Plain With Sentry Diff
b193867 1.58 MiB 2.19 MiB 620.00 KiB
3d205d0 1.58 MiB 2.10 MiB 532.97 KiB
22ff2c7 0 B 0 B 0 B
a5ab36f 1.58 MiB 2.12 MiB 555.26 KiB
539ca63 1.58 MiB 2.12 MiB 551.41 KiB
dba088c 1.58 MiB 2.13 MiB 558.99 KiB
4e3e79d 0 B 0 B 0 B
7314dbe 1.58 MiB 2.10 MiB 533.45 KiB
ad8da22 1.58 MiB 2.29 MiB 719.83 KiB
bb0ff41 0 B 0 B 0 B

Previous results on branch: feat/scope-set-environment

Startup times

Revision Plain With Sentry Diff
284a8f9 319.11 ms 381.14 ms 62.03 ms

App size

Revision Plain With Sentry Diff
284a8f9 0 B 0 B 0 B

…nment

# Conflicts:
#	sentry-android-core/src/main/java/io/sentry/android/core/ApplicationExitInfoEventProcessor.java
#	sentry-android-core/src/test/java/io/sentry/android/core/ApplicationExitInfoEventProcessorTest.kt
@bitsandfoxes
bitsandfoxes marked this pull request as ready for review July 17, 2026 13:17

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f3b38ec. Configure here.

observer.setEnvironment(environment);
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scope clear omits environment

Medium Severity

Scope.clear() resets fields like level but leaves the new environment field untouched, so a cleared scope can still apply a stale environment to events via applyScope and outrank SentryOptions defaults.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit f3b38ec. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant